<template>
  <label class="checkbox-wrapper">
    <input type="checkbox" v-model="checked" />
    <i class="icon"></i>
  </label>
</template>

<script>
export default {
  name: "checkbox",
  props: {
    value: Boolean
  },
  computed: {
    checked: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.checkbox-wrapper {
  height: auto;
  line-height: 0;
  input {
    display: none;
    &:checked + i {
      background-image: url("~@/assets/images/common/checked.png");
    }
  }
  i {
    $w_h: 0.14rem;
    display: inline-block;
    width: $w_h;
    height: $w_h;
    vertical-align: middle;
    background-size: 100% 100%;
    background-image: url("~@/assets/images/common/check.png");
  }
}
</style>
